import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.PriorityQueue;

public class test {
    //无返回值无参数
    @FunctionalInterface
    interface NoParameterNoReturn {
        void test();
    }
    //无返回值一个参数
    @FunctionalInterface
    interface OneParameterNoReturn {
        void test(int a);
    }
    //无返回值多个参数
    @FunctionalInterface
    interface MoreParameterNoReturn {
        void test(int a,int b);
    }
    //有返回值无参数
    @FunctionalInterface
    interface NoParameterReturn {
        int test();
    }
    //有返回值一个参数
    @FunctionalInterface
    interface OneParameterReturn {
        int test(int a);
    }
    //有返回值多参数
    @FunctionalInterface
    interface MoreParameterReturn {
        int test(int a,int b);
    }

    public static void main(String[] args) {
        HashMap<Integer, String> map = new HashMap<>();
        map.put(1, "hello");
        map.put(2, "bit");
        map.put(3, "hello");
        map.put(4, "lambda");
        map.forEach((k,v)-> System.out.println(k + "=" + v));
    }
    public static void main6(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("Hello");
        list.add("bit");
        list.add("hello");
        list.add("lambda");
        list.sort(
                (str1,str2)-> str1.length() - str2.length()
        );
        System.out.println(list);
    }
    public static void main5(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("Hello");
        list.add("bit");
        list.add("hello");
        list.add("lambda");
        list.forEach(str -> System.out.println(str+" "));

    }
    public static void main4(String[] args) {
        int count = 10;
        MoreParameterNoReturn moreParameterNoReturn = (int a,int b) -> {
            System.out.println(count);
            System.out.println(a+b);
        };

        //count = 99;
    }
    public static void main3(String[] args) {
        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o1.compareTo(o2);
            }
        });

        PriorityQueue<Integer> priorityQueue1 =
                new PriorityQueue<>((o1,o2)->o1.compareTo(o2));

    }
    public static void main2(String[] args) {
        NoParameterReturn noParameterReturn = () -> 10;
        System.out.println(noParameterReturn.test());
        OneParameterReturn oneParameterReturn = a-> a;
        System.out.println(oneParameterReturn.test(10));
        MoreParameterReturn moreParameterReturn = (a,b) -> a+b;
        System.out.println(moreParameterReturn.test(10,20));
    }
    public static void main1(String[] args) {
        NoParameterNoReturn noParameterNoReturn = new NoParameterNoReturn(){
            @Override
            public void test(){
                System.out.println("测试");
            }
        };
        noParameterNoReturn.test();
        NoParameterNoReturn noParameterNoReturn1 = ()->System.out.println("测试2");
        noParameterNoReturn1.test();
        OneParameterNoReturn oneParameterNoReturn = a-> System.out.println(a);
        oneParameterNoReturn.test(10);
        MoreParameterNoReturn moreParameterNoReturn = (a,b) -> System.out.println(a+b);
        moreParameterNoReturn.test(1,2);
    }
}
